import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OptionsVO, OptionsForm, OptionsQuery } from '@/api/answer/options/types';

/**
 * 查询选项列表
 * @param query
 * @returns {*}
 */

export const listOptions = (query?: OptionsQuery): AxiosPromise<OptionsVO[]> => {
  return request({
    url: '/answer/options/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询选项详细
 * @param optionId
 */
export const getOptions = (optionId: string | number): AxiosPromise<OptionsVO> => {
  return request({
    url: '/answer/options/' + optionId,
    method: 'get'
  });
};

/**
 * 新增选项
 * @param data
 */
export const addOptions = (data: OptionsForm) => {
  return request({
    url: '/answer/options',
    method: 'post',
    data: data
  });
};

/**
 * 修改选项
 * @param data
 */
export const updateOptions = (data: OptionsForm) => {
  return request({
    url: '/answer/options',
    method: 'put',
    data: data
  });
};

/**
 * 删除选项
 * @param optionId
 */
export const delOptions = (optionId: string | number | Array<string | number>) => {
  return request({
    url: '/answer/options/' + optionId,
    method: 'delete'
  });
};
